package com.heima.feigns.fallback;

import com.heima.feigns.BehaviorFeign;
import com.heima.model.behavior.pojos.ApBehaviorEntry;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @Description:
 * @Version: V1.0
 */
@Component
@Slf4j
public class BehaviorFeignFallback implements FallbackFactory<BehaviorFeign> {

    @Override
    public BehaviorFeign create(Throwable throwable) {
        return new BehaviorFeign() {
            @Override
            public ResponseResult<ApBehaviorEntry> findByUserIdOrEquipmentId(Integer userId, Integer equipmentId) {
                log.info("参数1: {}, 参数2：{}",userId, equipmentId);
                log.error("执行远程调用  BehaviorFeignFallback  findByUserIdOrEquipmentId , 异常的原因:{}",throwable.getMessage());
                return ResponseResult.errorResult(AppHttpCodeEnum.REMOTE_SERVER_ERROR);
            }
        };
    }
}
